package com.xmy.cultivate.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xmy.cultivate.entity.AuthAdminContent;
import com.xmy.cultivate.entity.CancellationRate;
import com.xmy.cultivate.entity.RecordCourse;
import com.xmy.cultivate.entity.response.ArrivalRate;
import com.xmy.cultivate.entity.response.RepairLessonRs;
import com.xmy.cultivate.entity.views.LeadDataRs;
import com.xmy.cultivate.entity.views.StudentClassLogRep;
import com.xmy.cultivate.respons.AssignMoney;
import com.xmy.cultivate.util.Result;
import org.apache.ibatis.annotations.Param;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 记止课 服务类
 * </p>
 *
 * @author baomidou
 * @since 2022-08-10
 */
public interface IRecordCourseService extends IService<RecordCourse> {

    List<CancellationRate> selectCancellationRate(String schoolId, Integer yearPart, Integer quarterNum, String subjectsId, Integer type, LocalDateTime startDate, LocalDateTime endDate, String lessonType, String yearClassId, String classTypeIdStr, String startLessonNum, String endLessonNum, String teacherId, AuthAdminContent authAdminContent, LeadDataRs leadDataRs);

    IPage<CancellationRate> cancellationRateDetail(IPage<?> iPage, String schoolId, Long teacherId, Integer yearPart, Integer quarterNum, String subjectsId, Integer type, LocalDateTime startDate, LocalDateTime endDate, String lessonType, String gradeId, Integer detailType, String yearClassId, String classTypeIdStr, String startLessonNum, String endLessonNum, AuthAdminContent authAdminContent, LeadDataRs leadDataRs);

    public abstract List<CancellationRate> cancellationRateTeamList(String schoolId, Integer yearPart, Integer quarterNum, String subjectsId, LocalDateTime startDate, LocalDateTime endDate, String yearClassId, String classTypeIdStr, String teamId, String classify, String trackType, String startLessonNum, String endLessonNum, AuthAdminContent authAdminContent, LeadDataRs leadDataRs);

    public abstract IPage<CancellationRate> cancellationRateTeamDetail(IPage<?> iPage, String schoolId, Long teacherId, Integer yearPart, Integer quarterNum, String subjectsId, LocalDateTime startDate, LocalDateTime endDate, String gradeId, Integer detailType, String yearClassId, String classTypeIdStr, String teamId, String classify, String trackType, String startLessonNum, String endLessonNum, AuthAdminContent authAdminContent, LeadDataRs leadDataRs);

    public abstract List<RecordCourse> selectExamination(QueryWrapper queryWrapper, String nowData);

    List<ArrivalRate> arrivalRate(String schoolId, String SubjectsId, Integer YearPart, Integer QuarterNum, String TeacherName, String StartDate, String EndDate, Integer type, String timeStart, String timeEnd, List<Long> baseSchoolIdList, Integer lessonType, String yearClassId, String trackId, String isTeamDetails, String classify, String trackType, String teamId, String name, String teacherId, String startLessonNum, String endLessonNum, String isCall, String isRebrush, String isYearClass, Long adminId, AuthAdminContent authAdminContent);

    IPage<RecordCourse> arrivalRateDetail(IPage<?> page, String schoolId, String subjectsId, String yearPart, String quarterNum, String StartDate, String EndDate, String gradeId, String teacherId, String type, String status, String timeStart, String timeEnd, Integer lessonType, String detailType, String yearClassIdStr, String classify, String trackType, String teamId, String startLessonNum, String endLessonNum, String isCall, String isRebrush, AuthAdminContent authAdminContent, LeadDataRs leadDataRs);

    IPage<RecordCourse> tardinessRateDetail(IPage<?> page, String schoolId, String subjectsId, String yearPart, String quarterNum, String StartDate, String EndDate, String gradeId, String teacherId, String type, String status, String timeStart, String timeEnd, Integer lessonType, String mode, String punctuality, String punctualityType, String yearClassIdStr, String classify, String trackType, String teamId, String startLessonNum, String endLessonNum, String isCall, String detailType, String isRebrush, AuthAdminContent authAdminContent, LeadDataRs leadDataRs);

    public abstract List<AssignMoney> classHouseMoney(Map reMap);

    public abstract Integer headcount(Map reMap);

    public abstract HashMap<String, Integer> getRepairCourse(Map reMap);

    List<ArrivalRate> tardinessRate(String[] schoolIdList, String SubjectsId, Integer YearPart, Integer QuarterNum, String TeacherName, String StartDate, String EndDate, Integer type, String timeStart, String timeEnd, List<Long> baseSchoolIdList, Integer lessonType, String schoolId, String yearCalssIdStr, String trackId, String isTeamDetails, String classify, String trackType, String teamId, String name, String startLessonNum, String endLessonNum, String teacherId, String isRebrush, String isYearClass, AuthAdminContent authAdminContent);

    /**
     * 获取补课人数列表
     */
    List<RepairLessonRs> getRepairLesson(String schoolIdStr, String schoolId, String yearPart, String quarterNum, String type, String subjectsId, String startDate, String endDate, Integer lessonType, String yearClassId);

    /**
     * 获取补课人数详情
     */
    List<RepairLessonRs> getRepairLessonDetail(String schoolIdStr, String yearPart, String quarterNum, String type, String subjectsId, String startDate, String endDate, Integer lessonType, Long teacherId, String gradeId, String studentName, String yearClassId);

    /**
     * 获取补课人数战队列表
     */
    List<RepairLessonRs> getRepairLessonTeamList(String yearPart, String quarterNum, String type, String subjectsId, String startDate, String endDate, Integer lessonType, String yearClassId, String classify, String trackType, String teamId);

    /**
     * 获取补课人数战队详情
     */
    List<RepairLessonRs> getRepairLessonTeamDetail(String yearPart, String quarterNum, String type, String subjectsId, String startDate, String endDate, Integer lessonType, Long teacherId, String gradeId, String studentName, String yearClassId, String classify, String trackType, String teamId);

    /**
     * 课时核对列表（上课记录）
     */
    public abstract IPage<StudentClassLogRep> studentClassLog(IPage<StudentClassLogRep> page, Wrapper wrapper, String yearPart, String quarter, String startDate, String endDate, String status, String schoolId, String yearClassId, String subjectsId, String studentName, String courseType, String checkType, String gradeId, String staffId, String isOther);

    public abstract IPage<StudentClassLogRep> studentClassLogParticulars(IPage<StudentClassLogRep> page, Wrapper wrapper);

    public abstract IPage<StudentClassLogRep> studentClassLogParticulars2(IPage<StudentClassLogRep> iPage, String yearPart, String quarterNum, String startDate, String endDate, String schoolId, String subjectsId, String checkType, String teacherId, String lessonType, String isRestrict, AuthAdminContent authAdminContent, LeadDataRs leadDataRs);


    /**
     * 金额
     */
    public abstract BigDecimal studentClassTeacherGetMoney(Wrapper wrapper);

    /**
     * 核对率
     */
    public abstract List<StudentClassLogRep> studentClassLogRate(String schoolId, String startDate, String endDate, String subjectsId, String yearPart, String quarterNum, String type, AuthAdminContent authAdminContent, LeadDataRs leadDataRs);


    Result buckleCourseForHandle(Long recordCourseId);

    /**
     * 大于15次课的，扣除补课金额
     *
     * @param recordCourseId
     * @param byRecordId
     * @return
     */
    @Transactional
    Result greaterBuckleMoney(Long recordCourseId, Long byRecordId);

    RecordCourse getLeaveData(Integer yearPart,
                              Integer quarterNum,
                              Integer lessonType,
                              Long studentId,
                              Long subjectsId);

    Integer getLeaveCount(Integer yearPart,
                          Integer quarterNum,
                          Integer lessonType,
                          Long studentId,
                          Long subjectsId);

    StudentClassLogRep uncheckedCount(Wrapper wrapper, String yearPart, String quarter, String staffId);

    /**
     * 刷题到勤
     */
    List<RecordCourse> getBrushQuestionsDiligently(String schoolId,
                                                   String subjectsId,
                                                   String yearPart,
                                                   String quarterNum,
                                                   String StartDate,
                                                   String EndDate,
                                                   String gradeId,
                                                   String teacherId,
                                                   String status,
                                                   String timeStart,
                                                   String timeEnd,
                                                   Integer lessonType,
                                                   String yearClassIdStr,
                                                   String startLessonNum,
                                                   String endLessonNum,
                                                   String isRebrush,
                                                   Integer isCount,
                                                   String studentName,
                                                   String schoolType,
                                                   String teacherName,
                                                   Integer type
    );

    /**
     * 获取到课数据
     *
     * @param yearPart
     * @param quarterNum
     * @param studentId
     * @param subjectsId
     * @return
     */
    Integer getRecordCountArrive(Integer yearPart, Integer quarterNum, Long studentId, Long subjectsId);

    /**
     * 获取最近三个学期最后一次上课记录
     *
     * @param lessonType
     * @param studentId
     * @return
     */
    RecordCourse getRecordCourseByLastThreeQuarter(Integer yearPart, Integer quarterNum, Integer lessonType, Long studentId, String subjectsId);

    /**
     * @param yearPart
     * @param quarterNum
     * @param studentId
     * @param subjectsId
     * @param lessonType
     * @return
     */
    Integer getLackCount(Integer yearPart, Integer quarterNum, Long schoolId, Long studentId, Long subjectsId, Integer lessonType);

    Integer getMaxTaskLesson(Integer YearPart, Integer QuarterNum, String SubjectsId, Long courseVersionId, Integer categoryId);
}
